home *** CD-ROM | disk | FTP | other *** search
- //////////////////////////////////////////////////////////////////////
- // Pocket PC Game Programming
- //
- // CGameLibrary Header File
- //
- // This file includes the CGameLibrary class definition.
- //
- //////////////////////////////////////////////////////////////////////
-
- #pragma once
-
- #include "stdafx.h"
-
- //primary windows functions
- int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow);
- LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
-
- //game library event functions
- extern "C"
- {
- BOOL GameInit(HINSTANCE hInst);
- void GameStart(HWND hWnd);
- void GameEnd();
- void GameActivate(HWND hWnd);
- void GameEvent();
- void GamePaint(HWND hWnd);
- void StylusDown(int x, int y);
- void StylusMove(int x, int y);
- void StylusUp(int x, int y);
-
- //*** New events for Chapter 11 ******************************
- void ButtonPress(int iButtonID, POINT pt);
- void ButtonRelease(int iButtonID, POINT pt);
- //************************************************************
-
- }
-
- //color struct used by drawing routines
- struct COLOR
- {
- BYTE Red;
- BYTE Green;
- BYTE Blue;
- };
-
- //support functions
- void MsgBox(LPTSTR szMessage);
-
- ////////////////////////////////////////////////////////////
- // CGameLibrary
- // Primary class for the game library
- ////////////////////////////////////////////////////////////
- class CGameLibrary
- {
- protected:
- //pointer to the CGameLibrary object
- static CGameLibrary *pGameLib;
-
- TCHAR szWindowClass[40];
- TCHAR szTitle[40];
- BOOL bHibernate;
- BOOL bFullscreen;
- WORD wProgramIcon;
- int iFrameRate;
-
- //GDI-specific
- HINSTANCE hInstance;
- HWND hWindow;
-
- //GAPI-specific
- unsigned char *GAPIVidMem;
- BOOL bGAPIDisplay;
- GXDisplayProperties gxDisplay;
-
- //*** New variable for Chapter 11 ****************************
-
- GXKeyList gxKeys;
-
- //************************************************************
-
- public:
- //construct/destruct methods
- CGameLibrary(HINSTANCE hInst, LPTSTR szNewWindowClass);
- virtual ~CGameLibrary();
-
- //primary game library methods
- BOOL Initialize(int nCmdShow);
- LRESULT EventHandler(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
- void Error(LPTSTR szError);
- void Shutdown();
- int ScreenWidth() { return GetSystemMetrics(SM_CXSCREEN); };
- int ScreenHeight() { return GetSystemMetrics(SM_CYSCREEN); };
-
- //added in Chapter 12 **************************************************************
- void PrintText(HDC hdc, LPCTSTR strText, int x, int y, COLORREF color, int iBkMode);
- void FatalError(LPTSTR lpStr);
- LPWSTR GetPath(TCHAR *filename = _T(""));
- //**********************************************************************************
-
- //program instance methods
- HINSTANCE GetInstance() { return hInstance; };
- void SetInstance(HINSTANCE hInst) { hInstance = hInst; };
-
- //program window methods
- HWND GetWindow() { return hWindow; };
- void SetWindow(HWND hWnd) { hWindow = hWnd; };
-
- //window title methods
- LPTSTR GetTitle() { return szTitle; };
- void SetTitle(LPTSTR szNewTitle) { wcscpy(szTitle, szNewTitle); };
-
- //hibernate setting methods
- BOOL GetHibernate() { return bHibernate; };
- void SetHibernate(BOOL bSet) { bHibernate = bSet; };
-
- //fullscreen setting methods
- BOOL GetFullscreen() { return bFullscreen; };
- void SetFullscreen(BOOL bSet) { bFullscreen = bSet; };
-
- //icon setting methods
- WORD GetIcon() { return wProgramIcon; };
- void SetIcon(WORD wIcon) { wProgramIcon = wIcon; };
-
- //frame rate methods
- int GetFrameRate() { return iFrameRate; };
- void SetFrameRate(int iFrames) { iFrameRate = 1000/iFrames; };
-
- //GAPI functions and methods
- BOOL G_Enabled() { return bGAPIDisplay; };
- void G_SetDisplay(BOOL bSet) { bGAPIDisplay = bSet; };
- void G_BeginDraw();
- void G_EndDraw();
- int GetXPitch() { return gxDisplay.cbxPitch; };
- int GetYPitch() { return gxDisplay.cbyPitch; };
- int GetBitsPerPixel() { return gxDisplay.cBPP; };
- BOOL IsScreenFormat565() { return (gxDisplay.ffFormat | kfDirect565); };
- unsigned char *G_GetVidMem() { return GAPIVidMem; };
- BOOL G_ClearScreen(COLOR color);
- int G_DrawPixel16(unsigned char *VidMem, int X, int Y, COLOR color);
- void G_DrawSolidRect(unsigned char *VidMem, int iLeft, int iTop, int iRight, int iBottom, COLOR color);
-
- //return the static Class object
- static CGameLibrary *GetObj(void) { return pGameLib; };
-
- //grant MsgBox access to the class object
- friend void MsgBox(LPTSTR szMessage);
-
-
- };
-
- //global CGameLibrary pointer
- inline CGameLibrary *GameLib() { return CGameLibrary::GetObj(); };
-
-
-